var tableData = {
	url : ctp + "/projectController/projectSearch.shtml",
	propertys : [ "NAME", "CONTRACTOR", "ADDR" ,"PROJECTSTATE","HT"],
	hrefs : [ [ "function=projectUpdate", "recId=REC_ID", "修改", null ],[ "function=projectDelete", "recId=REC_ID", "删除", null ] ],
	//css:[null,null,null,null,"[STATE_CHAR][1=color:blue;,2=color:red;]"],//不同值的样式
	//maxLength:["TASKNAME=15"],
	links:[["function=viewContract","recId=REC_ID","4"]],//合同预览
	checkBox:["REC_ID",true],
	startLoad : function() {
		getListData(this);
	}
};

function viewContract(recId) {
	$.ajax({ 
	 	url: ctp + "/projectController/getProjectContracts.shtml",
	    data: {recId:recId},
		type : 'POST',
		async:false, 
		dataType: "json",
		success : function(result) {
			var list=result.list;
			var json={};
			var data=[];
			for (var i = 0; i < list.length; i++) {
				var cell={src:ctp + '/' + list[i].path,thumb:ctp + '/' + list[i].path};
				data.push(cell);
			};
			json.data=data;
			//图片弹框展示
			layui.layer.photos({
		        photos:json,
		        anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
		      });
		}
	});
}


function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
}
$(document).ready(function() {
	//页面加载时，加载列表
	searchData();

});


function projectDel() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要删除的记录！");
		return false;
	}
	jconfirm("del('" + recIds + "')", "是否要删除所选记录？");
}

function projectDelete(recIds) {
	jconfirm("del('" + recIds + "')", "是否要删除所选记录？");
}
function del(recIds) {
	$.ajax({
		url : ctp + "/projectController/projectDelete.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("删除成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}
	});
}

// 修改
function projectUpdate(recId) {
	dialogWin(550, 450, ctp + "/projectController/projectUpdate.shtml?recId="
			+ recId, "");
}

//详情
function projectDetail(recId) {
	dialogWin(550, 450, ctp + "/projectController/projectDetail.shtml?recId="
			+ recId, "");
}

// 新增
function projectAdd() {
	dialogWin(550, 450, ctp + "/projectController/projectAdd.shtml", "");
}


// 重置密码
function resetPwd() {
	var recIds = getCheckIds(null, "projectid");
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("doReset('" + recIds + "')", "确定要重置所选用户的密码吗？");
}

function doReset(recIds) {
	$.ajax({
		url : ctp + "/projectController/resetPwd.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			jalert9(result);
			setTimeout(function() {
				searchData();
			}, 1000);
		}
	});
}


function projectDisable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要停用的用户！");
		return false;
	}
	jconfirm("Disable('" + recIds + "')", "是否要停用所选的用户？");
}
function Disable(recIds) {
	$.ajax({
		url : ctp + "/projectController/projectDisable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("停用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("停用用户失败！");
			}
		}
	});
}

function projectEnable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要启用的用户！");
		return false;
	}
	jconfirm("Enable('" + recIds + "')", "是否要启用所选的用户？");
}
function Enable(recIds) {
	$.ajax({
		url : ctp + "/projectController/projectEnable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("启用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("启用用户失败！");
			}
		}
	});
}


//导出系统用户
function sysprojectExportConfirm(recId){
	var formSerialize =$("#form1").serialize();
	jconfirm("exportSysUser('"+formSerialize+"')","确认要导出系统用户信息吗？");	
}
function exportSysUser(formSerialize){
	location.href=ctp+"/projectController/exportSysUser.shtml?"+formSerialize;
}


//用户信息导入界面跳转
function sysprojectImportpage(){
	dialogWin(550,450,ctp+"/projectController/sysprojectImportpage.shtml","用户信息导入");
}

function testFunction(){
	//layOpenWindow('新窗口1', '5','5','500','500','http://www.baidu.com');
	//layOpenWindow('新窗口2', '10','10','200','200','http://www.baidu.com');
	//layer.load(10); //风格1的加载
	//layConfirm('nihao',hello(1));
	dialogWin(550, 450, ctp + "/projectController/project.shtml", "");
}






















